﻿namespace Community.CsharpSqlite.Entity
{
    /*
    ** An instance of the following structure holds all information about a
    ** WHERE clause.  Mostly this is a container for one or more WhereTerms.
    */

    public class WhereClause
    {
        public Parse pParse; /* The parser context */
        public WhereMaskSet pMaskSet; /* Mapping of table cursor numbers to bitmasks */
        public ulong vmask; /* ulong identifying virtual table cursors */
        public byte op; /* Split operator.  TokenKeyword.TK_AND or TokenKeyword.TK_OR */
        public int nTerm; /* Number of terms */
        public int nSlot; /* Number of entries in a[] */
        public WhereTerm[] a; /* Each a[] describes a term of the WHERE cluase */
#if (SQLITE_SMALL_STACK)
public WhereTerm[] aStatic = new WhereTerm[1];    /* Initial static space for a[] */
#else
        public WhereTerm[] aStatic = new WhereTerm[8]; /* Initial static space for a[] */
#endif

        public void CopyTo(WhereClause wc)
        {
            wc.pParse = pParse;
            wc.pMaskSet = new WhereMaskSet();
            pMaskSet.CopyTo(wc.pMaskSet);
            wc.op = op;
            wc.nTerm = nTerm;
            wc.nSlot = nSlot;
            wc.a = (WhereTerm[]) a.Clone();
            wc.aStatic = (WhereTerm[]) aStatic.Clone();
        }
    };
}